package top.lingchen.spring5.testdemo;

import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import top.lingchen.spring5.config.SpringConfig;
import top.lingchen.spring5.service.UserService;

/**
 * @Author 凌宸
 * @create 2021-11-28 下午 7:04
 * @Description
 * @Version 1.0
 */
public class TestSpring5Demo1 {
    @Test
    public void testService(){
        ApplicationContext context =
                new ClassPathXmlApplicationContext("bean1.xml");
        UserService userService = context.getBean("userService", UserService.class);
        System.out.println(userService);
        userService.add();
        /**
         * top.lingchen.spring5.service.UserService@23986957
         * 凌宸
         * service add ...
         * dao add ....
         */
    }

    @Test
    public void testService2(){
        ApplicationContext context =
                new AnnotationConfigApplicationContext(SpringConfig.class);
        UserService userService = context.getBean("userService", UserService.class);
        System.out.println(userService);
        userService.add();
    }
}
